package com.mmall.user.provider.controller;

import com.mmall.common.spring.security.LoginRequired;
import com.mmall.common.spring.security.UserSecurityContextHolder;
import com.mmall.user.api.bo.UserAddressBO;
import com.mmall.user.api.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hejianglong
 * @date 2019/10/25
 */
@RestController
@RequestMapping("/address")
public class UserAddressController {

    @Autowired
    private UserAddressService userAddressService;

    @GetMapping("/get")
    @LoginRequired
    public UserAddressBO getUserAddressInfo() {
        Long userId = UserSecurityContextHolder.getContext().getUserId();
        return userAddressService.getDefaultUserAddress(userId);
    }
}
